package com.xy.tryai.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author yi.xiao
 */
@RestController
@RequestMapping("/ai")
public class AiAskController {

    @Resource
    private OllamaChatModel ollamaChatModel;

    @GetMapping("/ask")
    public Flux<String> askAi(String question) {
        return ollamaChatModel.stream(question);
    }
}
